package couk.mmtdigital.sm.control.commands
{
	import flash.net.FileReference;
	import flash.net.URLRequest;
	
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;

	public class DownloadCommand extends SimpleCommand implements ICommand
	{
		private var defualtURL:String = "http://localhost/sm/amfphp/services/sm/";
		private var downloadURL:String;
		private var downloadObj:Object;
		
		private var downloadRequest:URLRequest;
		private var downFileReference:FileReference;
		
		override public function execute(notification:INotification):void{
			downloadObj = notification.getBody();
			downloadURL = defualtURL + downloadObj.folderName +"/"+ downloadObj.fileName;
			trace(downloadURL);
			
			downloadRequest = new URLRequest(downloadURL);
			
			downFileReference = new FileReference();
			downFileReference.download(downloadRequest);
			
		}
	}
}